// @符号在build/webpack.base.conf.js中配置,表示'src'路径
import request from '@/utils/request'

export default {
  list() {
    return request({
      url: '/admin/edu/teacher/list',
      method: 'get'
    })
  },
  pageList(pageNum, limit, searchTeacher) {
    return request({
      url: `/admin/edu/teacher/list/${pageNum}/${limit}`,
      method: 'get',
      // post方式提交json字符串使用data,如果是get方式以url?k=v的形式提交 使用params
      params: searchTeacher // axios会自动将params参数后的json对象转为k=v&k2=v2的形式提交
    })
  },
  removeById(id) {
    return request({
      url: `/admin/edu/teacher/remove/${id}`,
      method: 'delete'
    })
  },
  save(teacher) {
    return request({
      url: '/admin/edu/teacher/save',
      method: 'post',
      // 将请求参数转为json字符串 以请求体的方式提交[因为后端使用@RequestBody接受]
      data: teacher
    })
  },
  getById(id) {
    return request({
      url: `/admin/edu/teacher/get/${id}`,
      method: 'get'
    })
  },
  updateById(teacher) {
    return request({
      url: '/admin/edu/teacher/update',
      method: 'put',
      data: teacher
    })
  },
  // 根据id批量删除
  batchRemove(idList) {
    return request({
      url: '/admin/edu/teacher/batch-remove',
      method: 'delete',
      data: idList
    })
  },
  // 自动查找
  selectNameListByKey(key) {
    return request({
      url: `/admin/edu/teacher/list/name/${key}`,
      method: 'get'
    })
  }

}
